package com.woniu.controller;


import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.constant.HttpStatus;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.woniu.entity.CarManager;
import com.woniu.entity.Client;
import com.woniu.entity.DataRendering;
import com.woniu.entity.OverdueManagement;
import com.woniu.service.CarManagerService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@Api(value = "车辆信息模块", tags = {"抵质押物管理"})
@RestController
@RequestMapping("/carManagement")
public class CarManagerController extends BaseController {
    @Autowired
    CarManagerService carManagerService;

    @ApiOperation(value = "查询所有车辆信息", response= CarManager.class,  httpMethod="GET", tags = {"抵质押物管理"})
    @ApiImplicitParam(name = "carManager",value = "车辆信息实体",required = true)
    @PreAuthorize("@ss.hasPermi('test:export')")
    @Log(title = "客戶管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CarManager carManager) throws IOException {
        List<CarManager> list = carManagerService.exportCarList();
        ExcelUtil<CarManager> util = new ExcelUtil<>(CarManager.class);
        util.exportExcel(response,list,"车辆信息数据");
    }
    @ApiOperation(value = "查询所有的车辆信息列表", response= CarManager.class,  httpMethod="GET", tags = {"抵质押物管理"})
    @ApiImplicitParam(name = "carManager",value = "车辆信息实体",required = true)
    @GetMapping("/findAll")
    public TableDataInfo findAll(CarManager carManager) {
        startPage();
        System.out.println(carManager.toString());
        List<CarManager> all = carManagerService.findAll(carManager);
        return getDataTable(all);
    }

    @ApiOperation(value = "查询指定的车辆信息列表", response= CarManager.class,  httpMethod="GET", tags = {"抵质押物管理"})
    @ApiImplicitParam(name = "carManager",value = "车辆信息实体",required = true)
    @GetMapping("/{id}")
    public AjaxResult findOne(@PathVariable String id){
        return AjaxResult.success(carManagerService.findOne(id));
    }


    @ApiOperation(value = "导出车辆信息列表", response= CarManager.class,  httpMethod="GET", tags = {"抵质押物管理"})
    @ApiImplicitParam(name = "carManager",value = "车辆信息实体",required = true)
    @GetMapping("/exportList")
    public TableDataInfo exportCarList() {
        startPage();
        List<CarManager> all = carManagerService.exportCarList();
        return getDataTable(all);
    }
}
